========================================================================= 
Log Path: ./log/logexternal.log 
Program Path: /Users/yorke/Dropbox/kuwait_roll_call/2_analysis/replication/03_rep_external.R 
Working Directory: /Users/yorke/Dropbox/kuwait_roll_call/2_analysis/replication 
User Name: yorke 
R Version: 4.3.1 (2023-06-16) 
Machine: AS23C1Q05N arm64 
Operating System: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 
Base Packages: stats graphics grDevices utils datasets methods base 
Other Packages: tidylog_1.1.0 logr_1.3.8 common_1.1.3 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0 
Log Start Time: 2024-07-24 10:12:44.436702 
========================================================================= 

> #### Replication Code for:
> #### Legislative Cooptation in Authoritarian Regimes: Policy Cooperation in the Kuwait National Assembly
> #### Authors: Daniel Tavana and Erin York
> #### Created: 07/22/24
> 
> # this code replicates Figure 1 in the main text
> # # this code requires downloading V-Dem Country-Year Data v11.1
> # see READ ME file for more details and download link
> 
> rm(list = ls())
> 
> library(tidyverse)
> library(logr)
> 
> options("logr.autolog" = TRUE)
> 
> # Open the log
> lf <- log_open(file.path("logexternal.log"))
> 
> # Send message to log
> log_code()
> 
> 
> # Figure 1 ----------------------------------------------------------------
> 
> 
> # load vdem data
> vdem <- read.csv(file = "vdem11.1.csv")
> vdem2020 <-
>   vdem %>%
>   filter(year == 2020) %>%
>   mutate(
>     regime_type = case_when(
>       v2x_regime == 0 ~ "Autocracy",
>       v2x_regime == 1 ~ "Autocracy",
>       v2x_regime == 2 ~ "Democracy",
>       v2x_regime == 3 ~ "Democracy")) %>%
>   dplyr::select(country_name,regime_type,v2lglegplo_osp,v2x_polyarchy,v2lglegplo_ord,v2dlconslt_ord,e_v2xlg_legcon_4C)
> 
> vdem2020 %>%
>   dplyr::group_by(regime_type) %>%
>   dplyr::summarize(median_edi = median(v2x_polyarchy, na.rm=T),
>                    median_lglegplot = median(v2lglegplo_osp, na.rm=T))
> vdem2020 %>%
>   filter(country_name == "Kuwait") %>%
>   dplyr::summarize(median_edi = median(v2x_polyarchy, na.rm=T),
>                    median_lglegplot = median(v2lglegplo_osp, na.rm=T))
> 
> f1 <- vdem2020 %>%
>   filter(country_name != "Armenia") %>%
>   ggplot(aes(v2lglegplo_osp, v2x_polyarchy, color=regime_type, shape=regime_type)) +
>   theme_bw() +
>   labs(x = "Is the approval of the legislature required to pass legislation? (0 = No, 1 = Usually, 2 = Always)",
>        y = "Electoral democracy index (0-1)",
>        title = "") +
>   scale_y_continuous(
>     breaks=seq(0.0, 1.0, 0.1),
>     minor_breaks = NULL,
>     limits = c(0.0, 1.0),
>     expand=c(0, 0)) +
>   scale_x_continuous(
>     breaks=seq(0.0, 2.0, 0.5),
>     minor_breaks = NULL,
>     limits = c(0.0, 2.0),
>     expand=c(0, 0.01)) +
>   theme(
>     legend.position = "bottom", # place legend on bottom of plot
>     legend.key.width = unit(1, "cm"), # set length of color bars in legend
>     legend.margin = margin(-10, 0, 0, 0), # set margins
>     legend.title = element_blank(), # remove legend title
>     plot.title = element_text(hjust = 0.5), # center title
>     text = element_text(size = 12, family = "Times"), # set font size
>     axis.text.y = element_text(size = 12), # set font size for y-axis tick labels
>     axis.text.x = element_text(size = 12), # set font size for y-axis labels
>     panel.grid.minor = element_blank(), # no minor grid for x-axis and y-axis
>     panel.grid.major.x = element_blank(), # no major grid for x-axis 
>     axis.line = element_line(colour = "black")) + # set color for x-axis and y-axis line
>   scale_shape_manual(values = c(1, 4), name = "") +
>   scale_color_manual(values = c("#FF0000", "#00A08A"), name = "") +
>   geom_vline(xintercept=1.68, color = "lightgray") +
>   geom_vline(xintercept=1.93, color = "lightgray") +
>   geom_hline(yintercept=0.284, color = "lightgray") +
>   geom_hline(yintercept=0.746, color = "lightgray") +
>   annotate("text", x = 1.58, y = 0.1, label = "Autocracy median = 1.68", family = "Times", size = 3) +
>   annotate("text", x = 1.83, y = 0.05, label = "Democracy median = 1.93", family = "Times", size = 3) +
>   annotate("text", x = 0.16, y = 0.321, label = "Autocracy median = 0.28", family = "Times", size = 3) +
>   annotate("text", x = 0.16, y = 0.787, label = "Democracy median = 0.75", family = "Times", size = 3) +
>   geom_text(
>     data = subset(vdem2020, country_name == "Kuwait"), color = "black",
>     aes(v2lglegplo_osp,.26,label = "Kuwait"), show.legend = FALSE, family = "Times") +
>   geom_point(position = position_jitter(seed = 1)) 
> f1
> 
> ggsave(f1, file = "Figure1.pdf", width = 9, height = 3.75)
> 
> 
> 
> ####
> 
> log_close()

filter: removed 27,013 rows (99%), 179 rows remaining

NOTE: Log Print Time:  2024-07-24 10:13:11.113579 
NOTE: Elapsed Time: 26.6697199344635 secs 

mutate: new variable 'regime_type' (character) with 2 unique values and 0% NA

NOTE: Log Print Time:  2024-07-24 10:13:11.409344 
NOTE: Elapsed Time: 0.295764923095703 secs 

filter: removed 178 rows (99%), one row remaining

NOTE: Log Print Time:  2024-07-24 10:13:11.576679 
NOTE: Elapsed Time: 0.167335033416748 secs 

filter: removed one row (1%), 178 rows remaining

NOTE: Log Print Time:  2024-07-24 10:13:11.932357 
NOTE: Elapsed Time: 0.355678081512451 secs 

========================================================================= 
Log End Time: 2024-07-24 10:13:13.144176 
Log Elapsed Time: 0 00:00:28 
========================================================================= 
